<template>
  <div class="com-container">
      12131
    <div class="com-charts" ref="stock_ref"></div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      echartInstance: null, //echarts实例化对象
      allData: null, //服务器获取的所有数据
    };
  },
  //计算属性
  computed: {
  },
  //页面初始化进行的操作
  mounted() {
    this.initecharts();
    this.getData();
    //屏幕大小监听事件
    window.addEventListener("resize", this.screenAdapter);
    this.screenAdapter();
  },

  methods: {
    //1. 初始化echarts
    initecharts() {
      this.echartInstance = this.$echarts.init(this.$refs.stock_ref, "chalk"); //初始化
      const creatOption = {};
      this.echartInstance.setOption(creatOption);
    },
    //获取数据
    async getData() {
      const { data: ret } = await this.$axios.get("stock");
      this.allData = ret;
      console.log(this.allData);
      this.updateecharts();
    },
    //数据处理
    updateecharts() {
      const dataOption = {};
      this.echartInstance.setOption(dataOption);
    },
    //分辨率自适应
    screenAdapter() {
      const adapterOption = {};
      this.echartInstance.setOption(adapterOption);
      // 手动的调用图表对象的resize 才能产生效果
      this.echartInstance.resize();
    },

  },
};
</script>

<style lang='' scoped>
</style>
